import React, { useState, useEffect, useCallback } from 'react'
import { Selector } from 'gantd'
import { fetchUnitDomainApi } from './service'
const UnitDomanSelector = (props: any, ref: any) => {
	const [dataSource, setDataSource] = useState([]);
	const fetchData = useCallback(async () => {
		const data = await fetchUnitDomainApi();
		setDataSource(data)
	}, [])
	useEffect(() => { fetchData() }, [])
	return <Selector selectorId="unitDomanSelector"  {...props} ref={ref} dataSource={dataSource} />
}

UnitDomanSelector.defaultProps = {
	labelProp: 'name',
	valueProp: 'domain'
}
export default UnitDomanSelector